001 /*
002 * Copyright 2005 Stephen J. McConnell.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
013 * implied.
014 *
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018
019 package net.dpml.state;
020
021 import java.io.Serializable;
022
023 /**
024 * Null state implementation.
025 *
026 * @author <a href="http://www.dpml.net">Digital Product Meta Library</a>
027 * @version 1.0.2
028 */
029 public final class NullState implements State, Serializable
030 {
031 /**
032 * Return the name of the state.
033 * @return the state name
034 */
035 public String getName()
036 {
037 return "";
038 }
039
040 /**
041 * Set the parent state.
042 * @param state the parent state
043 */
044 public void setParent( State state )
045 {
046 }
047
048 /**
049 * Return the parent state to this state or null if this is
050 * the root of a state graph.
051 * @return the parent state
052 */
053 public State getParent()
054 {
055 return null;
056 }
057
058 /**
059 * Return the state path. The path is composed of a sequence of
060 * states from the root to this state.
061 * @return the state path
062 */
063 public State[] getStatePath()
064 {
065 return new State[0];
066 }
067
068 /**
069 * Return the substates within this state.
070 * @return the substate array
071 */
072 public State[] getStates()
073 {
074 return new State[0];
075 }
076
077 /**
078 * Return the array of triggers associated with the state.
079 * @return the trigger array
080 */
081 public Trigger[] getTriggers()
082 {
083 return new Trigger[0];
084 }
085
086 /**
087 * Return the array of transtions associated with the state.
088 * @return the transition array
089 */
090 public Transition[] getTransitions()
091 {
092 return new Transition[0];
093 }
094
095 /**
096 * Return the array of operations associated with the state.
097 * @return the operation array
098 */
099 public Operation[] getOperations()
100 {
101 return new Operation[0];
102 }
103
104 /**
105 * Return the array of operations associated with the state.
106 * @return the operation array
107 */
108 public Interface[] getInterfaces()
109 {
110 return new Interface[0];
111 }
112
113 /**
114 * Test is the state is a terminal state.
115 * @return true if terminal
116 */
117 public boolean isTerminal()
118 {
119 return false;
120 }
121
122 /**
123 * Test is this state is equal to the supplied object.
124 * @param other the other object
125 * @return true if equal
126 */
127 public boolean equals( Object other )
128 {
129 if( null == other )
130 {
131 return false;
132 }
133 else
134 {
135 return ( other instanceof NullState );
136 }
137 }
138
139 /**
140 * Calcualte the hashcode for this instance.
141 * @return the hashcode value
142 */
143 public int hashCode()
144 {
145 return getClass().hashCode();
146 }
147 }